package com.esender.businesser.listener;

import com.esender.businesser.config.RabbitMQConfig;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class BusinessListener {
    @RabbitListener(queues = RabbitMQConfig.BUSINESS_QUEUE)
    public void receiveMessage(String msg, Channel channel, Message message) throws InterruptedException, IOException {
        // 预扣除优惠券
        Thread.sleep(400);
        System.out.println("通知商家成功！！" + msg);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }
}
